from alipay import AliPay
from alipay.utils import AliPayConfig

# 应用私钥字符串
app_private_key_string = open("./sy").read()
# 支付宝公钥字符串
alipay_public_key_string = open("./zfbgy").read()

# app_private_key_string = """
#     -----BEGIN RSA PRIVATE KEY-----
#     base64 encoded content
#     -----END RSA PRIVATE KEY-----
# """
#
# alipay_public_key_string = """
#     -----BEGIN PUBLIC KEY-----
#     base64 encoded content
#     -----END PUBLIC KEY-----
# """

alipay = AliPay(
    appid="2021000118629958",
    app_notify_url=None,  # the default notify path
    app_private_key_string=app_private_key_string,
    alipay_public_key_string=alipay_public_key_string,
    sign_type="RSA2",  # RSA or RSA2
    debug=True,  # False by default
    verbose=False,  # useful for debugging
    config=AliPayConfig(timeout=15)  # optional, request timeout
)

res=alipay.api_alipay_trade_page_pay(
    subject='充气版刘亦菲',
    out_trade_no='1000101010103',
    total_amount=float(9999),  # 只有生成支付宝链接时，不能用Decimal
    return_url='http://192.168.12.126:8081/actual-course',  # get回调 前端支付宝支付成功后的回调地址
    notify_url='http://192.168.12.126:8081/actual-course', # post回调 后端回调地址
)
print('https://openapi.alipaydev.com/gateway.do?'+res)
